package com.huike.web.controller.Demo01_EasyExcel;

import com.alibaba.excel.EasyExcel;

import java.util.List;

/**
 * @author BossSkill
 * @ClassName: ExcelRead
 * @date 2022/5/27 9:30
 * @Description:
 */
public class ExcelRead {

    public static void main(String[] args) {
        String filePath = "C:\\Users\\Lenovo\\Desktop\\A.xlsx";

//读取excel
//EasyExcel.read(哪个文件).sheet(那张sheet表).head(表头什么样子).headRowNumber(表头占几行).registerReadListener(处理数据的监听器类).doRead()
        EasyExcel.read(filePath).sheet(0).head(Student.class).headRowNumber(1).registerReadListener(

                new ExcelHandler<Student>()
                {
                    @Override
                    public void handle(List<Student> dataList)
                    {
                        for(Student stu: dataList)
                        {
                            System.out.println(stu.toString());
                        }
                    }
                }

        ).doRead();
    }

}
